package com.sgb.goods.view.adapter.order;

import android.view.View;

import androidx.databinding.ObservableBoolean;
import androidx.databinding.ViewDataBinding;

import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.goods.BR;
import com.sgb.goods.R;
import com.sgb.goods.entity.order.OrderPayDetailEntity;
import com.sgb.goods.utils.base.adapter.BaseCommonAdapter;

/**
 * 描述：商品订单-付款（收款）信息-付款约定
 *
 * @author qiangHeNoo
 * <p>
 * 时间：2021.12.20
 */
public class PaymentAgreementAdapter extends BaseCommonAdapter<OrderPayDetailEntity> {

    private View.OnClickListener listener;
    public ObservableBoolean isDaiQueRen = new ObservableBoolean();

    public PaymentAgreementAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder baseHolder, ViewDataBinding dataBinding, OrderPayDetailEntity entity) {
        dataBinding.setVariable(BR.adapter, this);
        dataBinding.setVariable(BR.viewModel, entity);
        if (baseHolder.getLayoutPosition() == 0) {
            baseHolder.itemView.findViewById(R.id.divider_view).setVisibility(View.GONE);
        }else {
            baseHolder.itemView.findViewById(R.id.divider_view).setVisibility(View.VISIBLE);
        }
    }

    /**
     * 设置是否待确认与履约中订单流转状态，用于显示隐藏某些字段
     *
     * @param orderProcessState orderProcessState    订单流程状态 1：待接单 2：待确认 3：履约中 4：已完成 5：已取消
     */
    public void setIsDaiQueRen(int orderProcessState) {
        isDaiQueRen.set(2 == orderProcessState || 1 == orderProcessState);
    }

    /**
     * 设置视图监听器
     */
    public void setOnclickListener(View.OnClickListener listener) {
        this.listener = listener;
    }

    /**
     * 付款详情 点击事件
     */
    public synchronized void paymentDetailsOnclick(View view) {
        if (null != this.listener) {
            this.listener.onClick(view);
        }
    }

}
